import request from '@/utils/request'
export function getTemplateList(id) {
  return request({
    url: '/api/template/getdata',
    method: 'get',
    params: {
      'doc_id': id
    }
  })
}
export function getTemplateRoot(doc_id) {
  return request({
    url: '/api/template_list/getid',
    method: 'get',
    params: {
      'doc_id': doc_id
    }
  })
}
export function getTemplateRoleList(role_id, inc_type) {

  return request({
    url: '/api/role/get_template',
    method: 'get',
    params: {
      role_id,
      inc_type
    }
  })
}
export function saveTemplate(data) {
  return request({
    url: '/api/templatetree/save',
    contentType: 'application/json',
    method: 'post',
    data
  })
}
export function saveTemplateOne(data) {
  return request({
    url: '/api/template/save_doc',
    contentType: 'application/json',
    method: 'post',
    data
  })
}

export function deleteNode(uuid) {
  return request({
    url: '/api/templatetree/del',
    contentType: 'application/json',
    method: 'post',
    data: { id: uuid }
  })
}
export function setStation(data) {
  return request({
    url: '/api/station/save',
    method: 'post',
    data
  })
}
export function saveTemplateRole(data) {
  return request({
    url: '/api/auth/save_template_role',
    method: 'post',
    data: data
  })
}
export function saveMenuTemplate(data) {
  return request({
    url: '/api/auth/save_menu_role',
    method: 'post',
    data: data
  })
}
export function saveUserTemplate(data) {
  return request({
    url: '/api/auth/save_user_template_role',
    method: 'post',
    data: data
  })
}
export function getTemplateRoleSet(role_id) {
  const listQuery = {
    page_no: 1,
    limit: 10000,
    sort: 'id desc',
    where: { and: [{ field: 'role_id', operator: '=', value: role_id }] }
  }
  return request({
    url: '/api/sl_doc_acllist/getlist',
    method: 'post',
    data: listQuery
  })
}
export function getTemplateUserSet(user_id) {
  const listQuery = {
    page_no: 1,
    limit: 10000,
    sort: 'id desc',
    where: { and: [{ field: 'user_id', operator: '=', value: user_id }] }
  }
  return request({
    url: '/api/sl_doc_acllist/getlist',
    method: 'post',
    data: listQuery
  })
}
